﻿CREATE VIEW [dbo].[V_MembershipRolePower]
	AS 
		SELECT  
		  p.Id AS PowerId, 
		  r.Id AS RoleId, 
		  COALESCE(rp.[GetFlag],  CAST(0 as bit)) AS [GetFlag], 
		  COALESCE(rp.[AddFlag],  CAST(0 as bit)) AS [AddFlag], 
		  COALESCE(rp.[EditFlag], CAST(0 as bit)) AS [EditFlag], 
		  COALESCE(rp.[DelFlag],  CAST(0 as bit)) AS [DelFlag], 
		  COALESCE(rp.[ExecFlag], CAST(0 as bit)) AS [ExecFlag] 
		FROM dbo.MembershipPower AS p
		INNER JOIN dbo.MembershipRole AS r ON 1=1
		LEFT JOIN dbo.MembershipRolePower AS rp ON rp.PowerId=p.Id AND rp.RoleId=r.Id
